<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon">
	<title>react_props</title>
</head>
<body>
  <div id="test"></div>

  <script type="text/javascript" src="../../js/react.development.js" ></script>
  <script type="text/javascript" src="../../js/react-dom.development.js"></script>
  <script type="text/javascript" src="../../js/babel.min.js"></script>
  <script type="text/javascript" src="../../js/prop-types.js"></script>

  <script type="text/babel">
    class Person extends React.Component {
      render(){
        const {name, age, sex} = this.props;
        return (<ul>
          <li>{name}</li>
          <li>{age}</li>
          <li>{sex}</li>
          </ul>)
      }
    }

    Person.propTypes = {
      name: PropTypes.string.isRequired,
      sex: PropTypes.string,
      age: PropTypes.number
    }
    Person.defaultProps = {
      sex: "保密"
    }

    const p = {name:"老王", age:18}
    //ReactDOM.render(<Person name={p.name} age={p.age} sex={p.sex}/>, document.getElementById('test'));
    ReactDOM.render(<Person {...p} />, document.getElementById('test'));
  </script>
</body>